<?php
class myFilter{
	public function doFilter(){
		$con = rareContext::getContext();
		$action = $con->getActionName();
		$module = $con->getModuleName();
		if(!($module=='image'&&$action=='upload')){
			$userID = Tool::_getSession('userID');
			$userName = Tool::_getSession('userName');
			$password = Tool::_getSession('password');
			if($userName==''||$password==''){
				forward('login');
			}else{
				$admin = new DaoAdmin();
				$user = $admin->getOne(" name='$userName' and password='$password'");
				if(empty($user)||$user['id']!=$userID){
					forward('login');
				}
				if($userID==1){
					Tool::_setCache('isAdmin',1);
				}
			}
		}
	}
}
?>
